﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataEquipmentSerial" @search="()=>{getTableDataEquipmentSerial();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="EquipmentId_FormItem" prop="EquipmentId" :label="$t('message.autotrans._Model_EquipmentSerial_Equipment')">
            <el-select v-model="searchDataEquipmentSerial.EquipmentId" clearable>
               <el-option v-for="item in stateEquipmentSerial.AllEquipments" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="SerialName_FormItem" prop="SerialName" :label="$t('message.autotrans._Model_EquipmentSerial_SerialName')">
            <el-input v-model="searchDataEquipmentSerial.SerialName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Description_FormItem" prop="Description" :label="$t('message.autotrans._Model_EquipmentSerial_Description')">
            <el-input v-model="searchDataEquipmentSerial.Description" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="BaudRate_FormItem" prop="BaudRate" :label="$t('message.autotrans._Model_EquipmentSerial_BaudRate')">
            <el-input v-model="searchDataEquipmentSerial.BaudRate" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="DataLength_FormItem" prop="DataLength" :label="$t('message.autotrans._Model_EquipmentSerial_DataLength')">
            <el-input v-model="searchDataEquipmentSerial.DataLength" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="StopBit_FormItem" prop="StopBit" :label="$t('message.autotrans._Model_EquipmentSerial_StopBit')">
            <el-input v-model="searchDataEquipmentSerial.StopBit" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Parity_FormItem" prop="Parity" :label="$t('message.autotrans._Model_EquipmentSerial_Parity')">
            <el-input v-model="searchDataEquipmentSerial.Parity" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Threshold_FormItem" prop="Threshold" :label="$t('message.autotrans._Model_EquipmentSerial_Threshold')">
            <el-input v-model="searchDataEquipmentSerial.Threshold" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Active_FormItem" prop="Active" :label="$t('message.autotrans._Model_EquipmentSerial_Active')">
            <el-select v-model="searchDataEquipmentSerial.Active" clearable>
               <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
               <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="TagId_FormItem" prop="TagId" :label="$t('message.autotrans._Model_EquipmentSerial_TagId')">
            <el-input v-model="searchDataEquipmentSerial.TagId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="TagName_FormItem" prop="TagName" :label="$t('message.autotrans._Model_EquipmentSerial_TagName')">
            <el-input v-model="searchDataEquipmentSerial.TagName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="GlobalPushlish_FormItem" prop="GlobalPushlish" :label="$t('message.autotrans._Model_EquipmentSerial_GlobalPushlish')">
            <el-select v-model="searchDataEquipmentSerial.GlobalPushlish" clearable>
               <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
               <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_EquipmentSerial_CreateTime')">
            <el-date-picker v-model="searchDataEquipmentSerial.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_EquipmentSerial_UpdateTime')">
            <el-date-picker v-model="searchDataEquipmentSerial.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_EquipmentSerial_CreateBy')">
            <el-input v-model="searchDataEquipmentSerial.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_EquipmentSerial_UpdateBy')">
            <el-input v-model="searchDataEquipmentSerial.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSerial/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSerial/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSerial/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSerial/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSerial/EquipmentSerialExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefEquipmentSerial" v-bind="tableDataEquipmentSerial">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSerial/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSerial/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/EquipmentManagement/EquipmentSerial/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageEquipmentManagementEquipmentSerialIndex;true;Digitalmes.EquipmentManagement.Controllers;EquipmentSerial">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { equipmentserialApi } from '/@/api/equipmentmanagement/equipmentserial';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateEquipmentSerial = reactive({
    
    AllEquipments: [] as any[],
});

const searchDataEquipmentSerial = ref({
        EquipmentId: null,
        SerialName: '',
        Description: '',
        BaudRate: null,
        DataLength: null,
        StopBit: null,
        Parity: null,
        Threshold: null,
        Active: undefined,
        TagId: null,
        TagName: '',
        GlobalPushlish: undefined,
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefEquipmentSerial = ref();
const tableDataEquipmentSerial = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
		  // {title:ci.proxy.$t('message.autotrans.Page设备'),key: 'EquipmentSerial_EquipmentId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page关联设备'),key: 'EquipmentSerial_Equipment',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page串口'),key: 'EquipmentSerial_SerialName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page说明'),key: 'EquipmentSerial_Description',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page波特率'),key: 'EquipmentSerial_BaudRate',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page数据长度'),key: 'EquipmentSerial_DataLength',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page停止位'),key: 'EquipmentSerial_StopBit',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page奇偶校验'),key: 'EquipmentSerial_Parity',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page最小长度'),key: 'EquipmentSerial_Threshold',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page激活'),key: 'EquipmentSerial_Active',type: 'switch',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page链接Tag'),key: 'EquipmentSerial_TagId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page标记名称'),key: 'EquipmentSerial_TagName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page全局发布'),key: 'EquipmentSerial_GlobalPushlish',type: 'switch',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'EquipmentSerial_CreateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'EquipmentSerial_UpdateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'EquipmentSerial_CreateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'EquipmentSerial_UpdateBy',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataEquipmentSerial = () => {
    tableRefEquipmentSerial.value.doSearch(equipmentserialApi().search, searchDataEquipmentSerial.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataEquipmentSerial)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataEquipmentSerial)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataEquipmentSerial)
};

// 删除
const onDelete = (row: any) => {
    equipmentserialApi().delete([row.ID]).then(() => { getTableDataEquipmentSerial()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefEquipmentSerial.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      equipmentserialApi().delete(selectedids).then(() => { getTableDataEquipmentSerial()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefEquipmentSerial.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataEquipmentSerial)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataEquipmentSerial)
};

const onExport = () => {
	const selected = tableRefEquipmentSerial.value.getSelectedRows();
	if (selected.length > 0) {
		equipmentserialApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		equipmentserialApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/EquipmentManagement/EquipmentSerial/GetEquipments',[],false).then(x=>{stateEquipmentSerial.AllEquipments = x});
        getTableDataEquipmentSerial();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

